
#import "AIMyLibraryShowCell.h"

@implementation AIMyLibraryShowCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self createUI];
    }
    return self;
}

- (void)createUI {
    
    self.showImageV = [[UIImageView alloc] init];
    self.showImageV.backgroundColor = [UIColor colorWithHexString:@"#E2E8ED"];
    [self.contentView addSubview:self.showImageV];
    self.showImageV.layer.cornerRadius = 5;
    self.showImageV.layer.masksToBounds = YES;
    self.showImageV.contentMode = UIViewContentModeScaleAspectFill;
    self.showImageV.clipsToBounds = YES;
    [self.showImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.offset(0);
    }];
    
    self.loadingLab = [[UILabel alloc] init];
    [self.showImageV addSubview:self.loadingLab];
    self.loadingLab.text = NSLocalizedString(@"制作中…", nil);
    self.loadingLab.textColor = [UIColor colorWithHexString:@"#000000"];
    self.loadingLab.font = kFontRegular(16);
    [self.loadingLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(self.showImageV);
    }];
    self.loadingLab.hidden = YES;
}

- (void)reloadCellWithModel:(AIMyHistoryCreateModel *)model {
    
    if ([model.state isEqualToString:@"PROCESSING"]) {
        self.loadingLab.hidden = NO;
        self.showImageV.image = [[UIImage alloc] init];
    } else {
        self.loadingLab.hidden = YES;
        [self.showImageV sd_setImageWithURL:[NSURL URLWithString:model.image_url]];
    }
}

- (void)reloadEmptyCell {
    self.loadingLab.hidden = YES;
    self.showImageV.image = [[UIImage alloc] init];
}

@end
